import React from 'react';
import { Breadcrumb } from 'antd';
import styles from './index.module.less';


class IBreadcrumb extends React.Component {
  static Item = Breadcrumb.Item

  render() {
    let title = this.props.title;
    if (!title) {
      const rawChildren = this.props.children;
      if (Array.isArray(rawChildren)) {
        title = rawChildren[rawChildren.length - 1].props.children
      } else {
        title = rawChildren.props.children
      }
    }

    return (
      <div className={styles.breadcrumb}>
        <Breadcrumb>
          {this.props.children}
        </Breadcrumb>
      </div>
    )
  }
}

export default IBreadcrumb